package com.weijianhuawen.wjblog.admin.controller;

import com.weijianhuawen.wjblog.admin.mode.vo.role.AddUserRoleReqVo;
import com.weijianhuawen.wjblog.admin.mode.vo.role.DeleteUserRoleReqVo;
import com.weijianhuawen.wjblog.admin.mode.vo.role.FindUserRolePageListReqVo;
import com.weijianhuawen.wjblog.admin.mode.vo.role.UpdateUserRoleReqVo;
import com.weijianhuawen.wjblog.admin.service.AdminRoleService;
import com.weijianhuawen.wjblog.common.aspect.ApiOperationLog;
import com.weijianhuawen.wjblog.common.utils.PageResponse;
import com.weijianhuawen.wjblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description:
 * @date: 2025-02-05 19:09
 */

@RequestMapping("/admin/role")
@Api(tags = "Admin 角色模块")
@RestController
public class AdminRoleController {
    // 注册角色服务对象
    @Autowired
    private AdminRoleService adminRoleService;

    // 获取用户角色分页列表
    @PostMapping("/page/list")
    @ApiOperation(value = "获取用户角色分页列表")
    @ApiOperationLog(description = "获取用户角色分页列表")
    public PageResponse findUserRolePageList(@RequestBody @Validated FindUserRolePageListReqVo vo) {
        return adminRoleService.findUserRolePageList(vo);
    }

    // 添加用户角色
    @PostMapping("/add")
    @ApiOperation(value = "添加用户角色")
    @ApiOperationLog(description = "添加用户角色信息")
    public Response addUserRole(@RequestBody @Validated AddUserRoleReqVo vo) {
        return adminRoleService.addUserRole(vo);
    }

    // 修改用户角色
    @PostMapping("/update")
    @ApiOperation(value = "修改用户角色")
    @ApiOperationLog(description = "修改用户角色")
    public Response updateUserRole(@RequestBody @Validated UpdateUserRoleReqVo vo) {
        return adminRoleService.updateUserRole(vo);
    }

    // 删除角色
    @PostMapping("/delete")
    @ApiOperation(value = "删除用户角色信息")
    @ApiOperationLog(description = "删除用户角色信息")
    public Response deleteUserRole(@RequestBody @Validated DeleteUserRoleReqVo vo) {
        return adminRoleService.deleteUserRole(vo);
    }


}
